<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script>
        window.onload = function() {
            // 给div绑定单击事件，单击变红色
            var div1 = document.getElementById("d1")
            div1.onclick = function() {
                this.style.backgroundColor = "red"
            }

            var btn = document.getElementById("btn1")
            btn.onclick = function(){
                alert("我被单击了！")
                // div1.onclick()
                div1.style.backgroundColor = "green"
            }

            
        }
    </script>
    <style>
        .div1{
            width: 100px;
            height: 100px;
            background-color: yellow;
        }
    </style>
</head>
<body>
    <div id="d1" class="div1"></div>
    <button id="btn1">按钮</button>
    <a href="09BOM编程常见API.html">09BOM编程常见API.html</a>
    
    
</body>
</html>